package com.mervin.patterns.singleton.type2;


/***************************************
 * @Auther: mervin
 * @Date: 2020-04-15 22:01
 * @Description:  饿汉式（静态代码块）
 ***************************************/
public class HungrySingleton {

    public static void main(String[] args) {
        System.out.println(Singleton.getInstance());
        System.out.println(Singleton.getInstance());
    }
}

class Singleton{

    private Singleton(){}

    private static Singleton instance;

    static {
        instance = new Singleton();
    }

    public static Singleton getInstance(){
        return instance;
    }
}

